﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Helpers;
using dotnethost.Models;
using MyToolKits;
using dotnethost.Watermark.Models;
namespace dotnethost.Watermark.Controllers
{
    public class WatermarkController : Controller
    {
        //
        // GET: /Wartermark/

        public ActionResult Index()
        {
            return View();
        }


        [HttpPost]
        public ActionResult Result(WatermarkFont font)
        {
            //if (ModelState.IsValid)
            //{
                var photo = WebImageUtil.GetImageFromRequest(Request);
                var watermarkText = Request["watermark"];
                WatermarkCreator creator = new WatermarkCreator(photo, HttpContext, font);
                try
                {
                    creator.AddWaterMark(watermarkText);
                }
                catch (Exception e)
                {
                    ViewBag.Error = e.Message;
                    return View();
                }
                ViewBag.MarkedImagePath = creator.MarkedImagePath;
                return View();
        //    }
        //    return View();
        }


    }
}
